package com.hz.ironc;

import com.hz.ironc.cloud.thritf.api.UserDto;
import com.hz.ironc.cloud.thritf.api.UserService;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

/**
 * Created by wq on 2017/1/21.
 */
public class Client {

    public static void main(String[] args) {
        TTransport transport = new TSocket("127.0.0.1", 9090);
        try {
            transport.open();
            TProtocol protocol = new TBinaryProtocol(transport);
            UserService.Client client = new UserService.Client(protocol);

            //接口调用
            UserDto user = client.getUser();
            //打印调用结果
            System.out.println("java client:" + user.getUsername());
            transport.close();
        } catch (TTransportException e) {
            e.printStackTrace();
        } catch (TException e) {
            e.printStackTrace();
        }
    }
}
